package monitor

import (
	"context"
	"gitee.com/alex_li/gpio/internal/pin"
	"github.com/lishimeng/go-log"
	"github.com/lishimeng/x/container"
)

func Watch(ctx context.Context) (err error) {

	var gpioMonitor = pin.New(ctx)
	var obj = *gpioMonitor
	container.Add(&obj)
	err = initPin()
	if err != nil {
		return
	}

	go func() {
		err = watchEvent(ctx)
		if err != nil {
			log.Info(err)
		}
	}()
	return
}
